const app = getApp()
Page({
  data: {
    AssTypeIdx: '', //行业选择
    inputtext:'',   //输入框的内容
    area_id:''
  },
  onLoad: function (options) {
    this.getCompanyArea()
  },
  getCompanyArea() {
      var that = this;
      wx.request({
        url: app.globalData.host + 'company/getCompanyArea',
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        method: 'GET',
        success: function (res) {
          console.log(res)
          wx.setStorageSync('AssocType', res.data.data)
          that.setData({
            AssocType: res.data.data
          })
        },
        fail: function (res) {},
        complete: function (res) {},
      })
  },
  bindPickerAssocType: function (e) { //行业选择
    var that = this;
    var AssTypeIdx = e.detail.value;
    var AssocType = that.data.AssocType;
    that.setData({
      AssTypeIdx,
      area_id: AssocType[AssTypeIdx].id
    })
  },
  searchTap(e){
    var that=this;
    that.setData({
      inputtext:e.detail.value
    })
  },
  // 点击搜索
  search(){
    var searchtext = this.data.inputtext || ''   //搜索框内容
    var area_id=this.data.area_id || 0    //area_id为行业id
    wx.navigateTo({
      url: '/pages/searchresult/searchresult?id='+area_id+"&text="+searchtext,
    })
  },
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})